package com.shroo8.footballblog.controllers.api;

import java.util.Locale;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shroo8.footballblog.bo.api.GetArticleBo;
import com.shroo8.footballblog.dto.api.ArticleDto;

/**
 * Handles requests for api get article by id.
 */
@Controller
public class GetArticleController {

	private static final Logger logger = LoggerFactory.getLogger(GetArticleController.class);

	@Resource(name="getArticleBo", type=com.shroo8.footballblog.bo.api.GetArticleBoImpl.class)
	private GetArticleBo getArticleBo;
	
	@RequestMapping(value = "/articles/{articleId}", method = RequestMethod.GET)
	public @ResponseBody ArticleDto getArticle(Locale locale, @PathVariable("articleId") String articleId) {
		logger.info("Welcome to getArticle! The client locale is {}.", locale);
		logger.info("article id is:" + articleId);
		ArticleDto articleDto = getArticleBo.getArticle(articleId);
		//ArticleDtoJsonWrapper getArticleResponse = new ArticleDtoJsonWrapper();
		
		//getArticleResponse.setReponseCode(200);
		//getArticleResponse.setResponseText("Ok");
		//getArticleResponse.setArticleDto(articleDto);

		return articleDto;
	}

}
